﻿<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of dangki
 *
 * @author Tuyet
 */
class Dangky extends CI_Controller {

//put your code here
    public $dk;

    function index() {
        $this->load->view('dangky');
    }

    function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model('m_dangky');
    }

    function dangki() {
        $email = $this->input->post('email');
        $HoTen = $this->input->post('HoVaTen');
        $TenDangNhap = $this->input->post('tendangnhap');
        $NgaySinh = $this->input->post('ngaysinh');
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            if ($HoTen != "") {
                if ($TenDangNhap != "") {
                    if ($NgaySinh != "") {
                        $data['HoTen'] = $HoTen;
                        $data['TenDangNhap'] = $TenDangNhap;
                        $data['NgayTao'] = date('Y-m-d');
                        $data['MatKhau'] = md5($this->input->post("matkhau"));
                        $data['Email'] = $email;
                        $data['GioiTinh'] = $this->input->post('gioitinh');
                        $data['NgaySinh'] = date('Y-m-d', strtotime($NgaySinh));
                        $data['SDT'] = $this->input->post('sdt');
                        $data['DiaChi'] = $this->input->post('diachi');
                        $data['MaQuyen'] = 3;
                        if ($this->m_dangky->addUser($data)) {
                            $data['msg'] = "Đã Đăng Ký Xong";
                            $data['pg'] = "category";
                            $this->load->view('info_success', $data);
                        }
                        //"add_date"  => date("Y-m-d H:i:s"),
                    } else {
                        echo 'Ngay sinh khong duoc de trong';
                    }
                } else {
                    echo 'Ten dang nhap khong duoc de trong';
                }
            } else {
                echo 'Ho va ten khong duoc de trong';
            }
        } else {
            echo 'Email Khong hop le';
        }
    }

}
